package com.hy.lightning.ds;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.hy.lightning.ds.redis.RedisConf;

import redis.clients.jedis.Jedis;

public interface RedisDataSource {
	
	/**
	 * redis数据库连接池配置
	 */
	static Map<String, RedisConf> conf_map = new ConcurrentHashMap<>();
	
	/**
	 * 初始化Redis数据库连接池
	 * @param redisConfs
	 */
	public static void initDataSource(RedisConf ...redisConfs){
		for(RedisConf jedisConf: redisConfs) {
			if (!conf_map.containsKey(jedisConf.getKey())) {
				conf_map.put(jedisConf.getKey(), jedisConf);
			}
		}
	}
	
	/**
	 * 获取Jedis连接对象
	 * @param key 数据库连接池key值
	 * @return
	 */
	Jedis getJedis(String key);
	
	/**
	 * 释放所有连接池
	 */
	void releasePoolAll();
	
	/**
	 * 释放指定连接池
	 * @param key
	 */
	void releasePool(String key);
}
